// Definition of a test model
// Copyright 2004 (C) Ralph Thomas

#ifndef MODEL_TEST_MODEL_H
#define MODEL_TEST_MODEL_H

#include <model/model.h>
#include <model/internal/receiverHelper.h>
#include <model/internal/url.h>
#include <toolkit/application.h>

namespace model {
	//
	/// The testModel implements a very simple model which supports
	/// the basic attributes and has some unique children. The test
	/// model is used to exercise various model-related code, such
	/// as the view.
	//
	class testModel : public model, public toolkit::idle {
		receiverHelper _receivers;	///< All subscribed
		url* _theUrl;			///< The URL we came from
		unsigned int _refCount;		///< Reference count
		adobe::array_t _children;	///< Our children
		char _foo;			///< Unique children thing
		bool _processing;		///< Are we in process()
	  public:
		//
		// ~testModel()
		//
		/// Virtual destructor. This is invoked by release() when
		/// the reference count reaches zero.
		//
		virtual ~testModel();
		//
		// testModel( const url* theUrl )
		//
		/// Create a new testModel from the given URL. The model
		/// will have some children, and should have some common
		/// attributes defined.
		///
		/// \param	theUrl	the URL describing this model.
		//
		testModel( const url* theUrl );
		//
		// bool init()
		//
		/// Initialize the model, make it ready for use. If this
		/// method returns false then the model is unusable and
		/// shouldn't be returned by the factory. The test model
		/// may sometimes report itself as invalid, just to test
		/// clients.
		///
		/// \return	true if the model may be returned by the
		///		factory, false otherwise.
		//
		bool init();
		//
		// from model/model.h
		//
		virtual model* retain() const;
		virtual void release();
		virtual void subscribe( receiver* r );
		virtual void unsubscribe( const receiver* r );
		virtual adobe::value_t getAttribute( const std::string& attrName )
			const;
		virtual void setAttribute( const std::string& attrName,
			const adobe::value_t& a );
		virtual adobe::value_t execute( const std::string& action, 
			const adobe::value_t& arg );
		//
		// from toolkit/application.h
		//
		virtual void process();
	};
};

#endif

